﻿<%@ WebHandler Language="C#" Class="search_imagehandler" %>


using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public class search_imagehandler : IHttpHandler
{
    
    public void ProcessRequest (HttpContext context) {
        SqlDataReader dr = null;
        SqlDataReader dr1 = null;
        SqlConnection conn = null;
        SqlConnection conn1 = null;
        SqlCommand cmd = null;
        SqlCommand cmd1 = null;

        try
        {
            String str = context.Request["imgid"];
         //   str = "M49180480";
            conn = new SqlConnection(System.Configuration.ConfigurationManager.
                 ConnectionStrings["ConnStr"].ConnectionString);
            //conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            //SqlConnection Don = new SqlConnection("Data Source=MRINAL-PC;Initial Catalog=onlinejobportal;User Id=sa;Password=mrinal");
            cmd = new SqlCommand("select profile_pic from properties where p_id='" + str + "'", conn);
            conn.Open();
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {

                context.Response.ContentType = "image/jpg";
                context.Response.BinaryWrite((byte[])dr["profile_pic"]);

            }
            if (dr != null)
                dr.Close();
        }
        finally
        {
            {
                conn1 = new SqlConnection(System.Configuration.ConfigurationManager.
                    ConnectionStrings["ConnStr"].ConnectionString);
                conn1.Open();
                cmd1 = new SqlCommand("select profile_pic from profile_picc ", conn1);

                dr1 = cmd1.ExecuteReader();
                while (dr1.Read())
                {

                    context.Response.ContentType = "image/jpg";
                    context.Response.BinaryWrite((byte[])dr1["profile_pic"]);

                }

                dr1.Close();
            }
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}